package top.superflow.core.control

import top.superflow.flow.config.Identifiable
import top.superflow.lang.StringUtils

class VisibleLevel {

}

object VisibleLevel extends Enumeration{
  type VisibleLevel = Value

  val GLOBAL =  Value("global")

  val WHITELIST = Value("whitelist")

  val GROUP = Value("group")

  val SESSION = Value("session")

  def isVisible(currentGroup : String, t : Identifiable) : Boolean = {
    if(t == null){
      return false
    }

    if(StringUtils.isBlank(t.getVisibleLevel) || StringUtils.equalsIgnoreCase(t.visibleLevel, GLOBAL.toString)){
      return true
    }

    if(StringUtils.equalsIgnoreCase(currentGroup, t.getGroup)){
      return true
    }

    return false
  }

}
